/*
    AuthorNote: ***
    Created By: Bambom Date:DATE
*/

using System.Collections.Generic;

namespace AutoChess
{
    internal class BEventEntryData
    {
        public object m_interfaceWrap;
    }
    class BEventMgr
    {
        private BEventDispatcher m_dispatcher = new BEventDispatcher();
        
        /// <summary>
        /// 封装了调用的代理函数
        /// </summary>
        private Dictionary<string,BEventEntryData> m_entry = new Dictionary<string, BEventEntryData>();

        public T GetInterface<T>()
        {
            string typeName = typeof(T).FullName;
            BEventEntryData entry;
            if (m_entry.TryGetValue(typeName, out entry))
            {
                return (T) entry.m_interfaceWrap;
            }

            return default(T);
        }

        /// <summary>
        /// 注册Wrap代理函数
        /// </summary>
        public void RegWrapInterface<T>(T callerWrap)
        {
            string typeName = typeof(T).FullName;
            BLogger.Assert(!m_entry.ContainsKey(typeName));
            
            var entry = new BEventEntryData();
            entry.m_interfaceWrap = callerWrap;
            m_entry.Add(typeName,entry);
        }

        public BEventDispatcher GetDispatcher()
        {
            return m_dispatcher;
        }

    }
}